/*
 * @Author: your name
 * @Date: 2021-08-02 00:14:12
 * @LastEditTime: 2021-11-22 11:00:19
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \aircityinit\src\router\index.js
 */
import Vue from "vue";
import VueRouter from "vue-router";
// 引入路由模块
import { TagPageRoute } from "./modules/tagpages";
import { AdministrationRoute } from "./modules/administration";
Vue.use(VueRouter);
// 获取原型对象上的push函数
const originalPush = VueRouter.prototype.push;
// 修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};
const routes = [
  {
    path: "/",
    // redirect: "/swday",
    redirect: "/home/xmxz",
  },
  {
    path: "/swday",
    component: () => import(/* webpackChunkName: "home" */ "../views/swday"),
  },
  {
    path: "/home",
    name: "home",
    component: () =>
      import(/* webpackChunkName: "home" */ "@/views/Home/Home.vue"),
    redirect: "/home/swyzt",
    children: [
      {
        path: "swyzt",
        name: "swyzt",
        component: () => import("../views/Home/swyzt"),
        redirect: "/home/swyzt/sssw",
        children: [
          {
            path: "sssw",
            name: "sssw",
            component: () => import("../views/Home/swyzt/sssw"),
          },
          {
            path: "swxz",
            name: "swxz",
            // component: () => import("../views/Home/swyzt/swxz"),
            component: () => import("../components/frame/frame.vue")
          },
          {
            path: "swjc",
            name: "swjc",
            component: () => import("../views/Home/swyzt/swjc"),
            redirect: "/home/swyzt/swjc/reservoir",
            children: [
              {
                path: "reservoir",
                name: "reservoir",
                component: () => import("../views/Home/swyzt/swjc/reservoir"),
              },
              {
                path: "rivercourse",
                name: "rivercourse",
                component: () =>
                  import("../views/Home/swyzt/swjc/river_course"),
              },
              {
                path: "Waterlogging",
                name: "Waterlogging",
                component: () =>
                  import("../views/Home/swyzt/swjc/Waterlogging"),
              },
              {
                path: "Mountaintorrent",
                name: "Mountaintorrent",
                component: () =>
                  import("../views/Home/swyzt/swjc/Mountain_torrent"),
              },
              {
                path: "dam",
                name: "dam",
                component: () => import("../views/Home/swyzt/swjc/dam"),
              },
              {
                path: "Tidelevel",
                name: "Tidelevel",
                component: () => import("../views/Home/swyzt/swjc/Tide_level"),
              },
            ],
          },
        ],
      },
      {
        path: "xmxz",
        name: "xmxz",
        component: () => import("../views/Home/xmxz"),
      },
      {
        path: "xmxzUsable",
        name: "xmxzUsable",
        component: () => import("../views/Home/xmxz/usablePush.vue"),
      },
    ],
  },

  // 在此插入路由模块
  TagPageRoute,
  AdministrationRoute,
  {
    path: "/404",
    name: "NotFound",
    component: () =>
      import(/* webpackChunkName: "notFound" */ "@/views/404/index.vue"),
  },
  {
    path: "*", //处理错误页面
    redirect: "/404",
  },
];

const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes,
});
// 添加路由守卫
// router.beforeEach((to, from, next) => {
//   // 可以添加登录前的导航守卫

//   console.log('to:', to);
//   console.log('from:', from);
//   next()
// })
export default router;
